<template>
  <div style="margin-bottom: 10px; padding-left: 5px">
    <div class="tophead">{{ temperature.iceBoxAreaName }} ({{ temperature.usedCount }}/{{ temperature.capacity }})</div>
    <div class="mainBody" v-if="temperature.iceBoxAreaType == 1">
      <div :class="{ er: showwarn && item.deviceWarnVo && item.deviceWarnVo.status != 0 }" class="maxbox"
        v-for="item in temperature.storageIceStatisticVoList" :key="item.iceBoxId">
        <p class="name">{{ item.iceBoxName }}</p>
        <div class="son">
          <img src="../img/ice.png" alt="" />
          <div style="flex: 1;justify-content: center;display: flex;">
            <span :style="{
              backgroundColor: item.deviceWarnVo && item.deviceWarnVo.status != 0 ? '#ffe7e9' : '',
            }" class="heat">{{ item.deviceWarnVo?.genTemperInfo.temperature ?
  item.deviceWarnVo?.genTemperInfo.temperature : '-' }}℃</span>
          </div>
        </div>
        <img v-if="item.deviceWarnVo && item.deviceWarnVo.status != 0" class="warnimg"
          :src="imgSrc[item.deviceWarnVo.status - 1]" alt="" />
        <div class="fa">
          <div class="possess" :style="{ width: `${item.mix}%` }"></div>
        </div>
      </div>
    </div>
    <div class="mainBody" v-else>
      <div :class="{ er: showwarn && item.deviceWarnVo && item.deviceWarnVo.status != 0 }" class="maxbox"
        style="width: 190px" v-for="item in temperature.storageIceStatisticVoList" :key="item.iceBoxId">
        <p>{{ item.iceBoxName }}</p>
        <div class="son">
          <img src="../img/ice.png" alt="" />
          <div class="xianzi">
            <p :style="{
              backgroundColor: item.deviceWarnVo && item.deviceWarnVo.genTemperInfo.status != 0 ? '#ffe7e9' : '',
            }" class="basic">
              {{ item.deviceWarnVo?.genTemperInfo.temperature }}℃
            </p>
            <p :style="{
              backgroundColor: item.deviceWarnVo && item.deviceWarnVo.zsMiddleTemperInfo.status != 0 ? '#ffe7e9' : '',
            }" class="basic">
              {{ item.deviceWarnVo?.zsMiddleTemperInfo.temperature }}℃
            </p>
            <p :style="{
              backgroundColor: item.deviceWarnVo && item.deviceWarnVo.zsBottomTemperInfo.status != 0 ? '#ffe7e9' : '',
            }" class="basic">
              {{ item.deviceWarnVo?.zsBottomTemperInfo.temperature }}℃
            </p>
          </div>
        </div>
        <div class="faendways">
          <div class="possess" :style="{ width: `${item.mix}%` }"></div>
        </div>
        <div class="fa">
          <div class="possess" :style="{ width: `${item.mix}%` }"></div>
        </div>
        <img v-if="item.deviceWarnVo && item.deviceWarnVo.status != 0" class="warnimg"
          :src="imgSrc[item.deviceWarnVo.status - 1]" alt="" />
      </div>
    </div>
  </div>
</template>
<script setup lang="tsx">
import oneWorn from '../img/温度报警icon.png'
import twoWorn from '../img/液位报警icon.png'
import threeWorn from '../img/同时报警icon.png'
const props = defineProps({
  temperature: {
    type: Object,
    default: {},
  },
  showwarn: {
    type: Boolean,
    default: false,
  },
});
const imgSrc = [oneWorn, twoWorn, threeWorn]
</script>
<style lang="less" scoped>
p {
  margin: 0;
}

.name {
  width: 150px;
  overflow: hidden; //超出的文本隐藏
  text-overflow: ellipsis; //溢出用省略号显示
  white-space: nowrap; //溢出不换行
}

.er {
  // border: 1px solid red;
  box-shadow: 0 0 5px red;
}

.tophead {
  border-radius: 1px;
  border-left: 4px solid orange;
  padding-left: 5px;
  margin-bottom: 10px;
  font-size: 16px;
}

.mainBody {
  display: flex;
  flex-wrap: wrap;
  font-size: 16px;
}

.maxbox {
  position: relative;
  width: 190px;
  margin: 0 15px 10px 0;

  .son {
    display: flex;
    align-items: center;

    img {
      width: 50px;
      height: 120px;
    }

    .heat {
      font-size: 20px;
      display: inline-block;
      text-align: center;
      width: 90px;
      background-color: #e5faf1;
      border-radius: 20%;
    }

    .basic {
      font-size: 16px;
      display: inline-block;
      text-align: center;
      width: 90px;
      padding: 2px 10px;
      background-color: #e5faf1;
      border-radius: 10%;
      margin-top: 5px;
    }

    .xianzi {
      display: flex;
      align-items: center;
      flex-direction: column;
      margin: 0 0 0 10px;
      flex: 1;
    }

    margin-bottom: 13px;
  }
}

.fa {
  width: 95%;
  height: 3px;
  position: absolute;
  bottom: -9px;
  border-radius: 1px;
  background-color: #d0d0d0;

  .possess {
    width: 50%;
    height: 3px;
    border-radius: 1px;
    background-color: orange;
  }
}

.faendways {
  position: absolute;
  right: -10px;
  bottom: 0;
  height: 100px;
  width: 3px;
  border-radius: 1px;
  background-color: #d0d0d0;

  .possess {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 3px;
    height: 40px;
    border-radius: 1px;
    background-color: orange;
  }
}

.warnimg {
  position: absolute;
  right: -20px;
  top: -25px;
}
</style>
